<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>异步编程</title>
    <script src="jquery.js"></script>
</head>
<body>
    <button id="play">播放</button>
    <p id="result">点击按钮获取歌词</p>

    <hr>
    
    <script>
        var lyric 
        // 布尔值记录状态 
        var isLoaded = false
        var isPlay = false

        setTimeout(function(){
            lyric = '1111'
            isLoaded = true
            if(isPlay){
                $('#result').text(lyric)
            }
        },4000)

        $('#play').click(function(){
            isPlay = true
            if(isLoaded){
                $('#result').text(lyric)
            }else{
                $('#result').text('歌词准备中')
            }
        })
    </script>
</body>
</html>